﻿
namespace Patterns4Net.ArchitectureExplorer.Diagram
{
    using System.Collections.Generic;
    using Mono.Cecil;

    public class MethodInfo : DiagramElement
    {
        private IList<PatternInfo> patterns = new List<PatternInfo>();

        public MethodInfo(string name, IEnumerable<string> parametersNames)
            : base(name)
        {
            this.ParametersNames = parametersNames;
        }

        public IEnumerable<string> ParametersNames { get; private set; }

        public IEnumerable<PatternInfo> Patterns
        {
            get { return this.patterns; }
        }

        public void AddPattern(PatternInfo pattern)
        {
            this.patterns.Add(pattern);
        }

        public override void Accept(DiagramVisitor visitor)
        {
            visitor.Visit(this);
        }

        public override string ToString()
        {
            return string.Format(
                "{0}({1}):{2}",
                this.Name,
                string.Join(",", this.ParametersNames),
                this.GetTag<MethodDefinition>().MethodReturnType.ReturnType.Name);
        }
    }
}
